<script type="text/javascript">

$(function(){
	$.post("inventorymanagement/getUserAndBanch",function(json){
		var activeUser = json.activeUser;
		var userNo=activeUser.userNo;
		var branchNo=activeUser.branchNo;
		$("input[name='empNo']").val(userNo);
		$("input[name='branchNo']").val(branchNo);	
})
	$.get("inventorymanagement/setTaskNo",setTaskNo,"json");
	//$("input[name='branchNo']").val("10000001");
	//$("input[name='empNo']").val("10000000");
	$("#addTask").click(function(){
		var $ditributeTaskNo = $("input[name='cardControlIdByDis']");
		//获取表格中的隐藏项目controlId
		var ditributeTaskNo = $("input[name='ditributeTaskNo']").val();
		var branchNo = $("input[name='branchNo']").val();
		var empNo = $("input[name='empNo']").val();
		var paramValue = ditributeTaskNo+"#"+branchNo+"#"+empNo;
		var cardControlIdList = "";
		$ditributeTaskNo.each(function(n,item){
			if(n==0){
				cardControlIdList = $(this).val();
			}else{
				cardControlIdList = cardControlIdList + "#" + $(this).val();
			}
		})
		console.log("选中的卡控制号是==>"+cardControlIdList);
		$("#addTask").attr("param",paramValue);
		$("#addTask").attr("list",cardControlIdList);
	});
})

//删除信息
function deleteItem(){
	if($("input[name='distributeItem']:checked").length < 1){
		 alertMsg.warn("您未选择数据！")
		 return false;
	 }
	var citizenCardNo="";
	var cardControlId="";
	var empNo = $("input[name='empNo']").val();
	var fileName = $("input[name='branchNo']").val()+$("input[name='ditributeTaskNo']").val();
	$("input[name='distributeItem']:checked").each(function(n,item){
		var array=$(this).val().split("#");
		if(n==0){
			citizenCardNo=array[0];
			cardControlId=array[8];
		}else{
			citizenCardNo = citizenCardNo + "$" + array[0];
			cardControlId = cardControlId + "$" + array[8];
		}	
	});
	console.log("选择的卡号是==>"+citizenCardNo);
	console.log("选择的卡控制号是==>"+cardControlId);
	//$.post("parameterCard/deleteProduct",{numPerPage:numPerPage,currentPage:currentPage,parm:parm,pageCount:pageCount}, getCardProductD,"json");
	$.post("inventorymanagement/deleteDistributeItem",{empNo:empNo,citizenCardNo:citizenCardNo,fileName:fileName,cardControlId:cardControlId}, loadDistributeInfo,"json");
}
	

function validateCheckBox(){
	if($("input[name='Busiparatasked']:checked").length <= 1){
		 alertMsg.warn("您未选择数据！")
		 return false;
	}
    if($("input[name='Busiparatasked']:checked").length > 2){
	      alertMsg.warn("不能选择多于1条数据！")
		 return false; 
	 }
}


function editCheckBox(){
	var $items = $("input[name='distributeItem']");
	if($items.length==0){
		alertMsg.warn("提交的数据为空！请先添加任务明细！")
		return false;
	}
	$("input[name='distributeItem']").attr("checked",true);
}
</script>
<form method="post" action="inventorymanagement/toTaskDetailInfo" class="pageForm required-validate" onsubmit="return validateCallback(this,navTabAjaxDone);" >	
	 <div class="searchBar">
	 <table class="searchContent">	
			<tr>
				<td><label>配送任务号:</label></td>
				<td><input id="ditributeTaskNo" name="ditributeTaskNo" size="20" value="" readonly="readonly"></td>
			</tr>
			<tr>
				<td><label>卡片数量:</label></td>
				<td><input id="cardAmount" name="cardAmount" size="20" value="" readonly="readonly"></td>	
			<tr>
			<tr>
				<td><label>网点编号:</label></td>
				<td><input id="branchNo" name="branchNo" size="20" value="" readonly="readonly"></td>
			</tr>
			<tr>
				<td><label>员工编号:</label></td>
				<td><input id="empNo" name="empNo" size="20" value="" readonly="readonly"></td>		
			</tr>
		</table>
	</div>
	 <div class="pageContent" >
	 	<div class="panelBar">
		<ul class="toolBar">
			<li><a id="addTask" class="add" href="inventorymanagement/queryRejectCardInfo" max="true" param="" list="" target="dialog" rel="queryRejectCard"><span>新增</span></a></li>
			<li><a class="delete" onclick="return deleteItem();"><span>删除</span></a></li>
			<!-- <li><a class="edit"  onclick="return updateBusiParam();"><span>修改</span></a></li> -->
		</ul>
	</div>
	<!-- <input name="Busiparatasked" type="checkbox" style="display:none" value="xxxxxxxxxxx" checked> -->
		<div id="distributetask">
		<table class="table" width="800" layoutH="298">
			<thead>
				<tr>
					<th width="5%" align="center"><input type="checkbox" name="distribute" group="distributeItem" class="checkboxCtrl"></th>
					<th width="8%" >序号</th>
					<th width="10%" >卡号</th>
					<th width="15%" >卡产品名称</th>
					<th width="10%" >卡片有效标志</th>
					<th width="15%" >制卡商</th>
					<th width="20%" >配送原因</th>
					<th width="0%" align="center" style="display:none;">卡产品代码</th>
					<th width="0%" align="center" style="display:none;">制卡商代码</th>
					<th width="0%" align="center" style="display:none;">配送原因代码</th>
					<th width="0%" align="center" style="display:none;">卡控制Id</th>
				</tr>
			</thead>
			<tbody id="ditributeDetail">
				
			</tbody>
		</table>
</div>
		<div class="formBar">
			<ul> 
				<li>
					<div class="buttonActive" ><div class="buttonContent" >
					<button type="submit" onclick="return editCheckBox();" >配送出库登记</button></div></div>
				</li>
				<li>
					<div class="buttonActive" ><div class="buttonContent" >
					<button type="submit" class="close" >关闭</button></div></div>
				</li>
			</ul>
		</div> 
	
</div>
	</form>